#pragma once
#include <qwidget.h>
#include <QSpinBox.h>
#include <gp_pnt.hxx>
#include <gp_vec.hxx>
#include <Precision.hxx>

class MainWindow;
class ShapeOperation;

struct RWTripleFloatInput
{
	QDoubleSpinBox* x;
	QDoubleSpinBox* y;
	QDoubleSpinBox* z;

	RWTripleFloatInput() = default;
	RWTripleFloatInput(QDoubleSpinBox* inX, QDoubleSpinBox* inY, QDoubleSpinBox* inZ)
	{
		x = inX;
		y = inY;
		z = inZ;
	}

	bool IsValid() const
	{
		return x && y && z;
	}

	bool IsNearlyZero(const Standard_Real theLinearTolerance = Precision::Confusion()) const
	{
		if (IsValid())
		{
			return GetValue().IsEqual(gp_XYZ(), theLinearTolerance);
		}
		return false;
	}

	void SetValue(const gp_Pnt& inPoint)
	{
		if (IsValid())
		{
			x->setValue(inPoint.X());
			y->setValue(inPoint.Y());
			z->setValue(inPoint.Z());
		}
	}
	void SetValue(const gp_Vec& inPoint)
	{
		if (IsValid())
		{
			x->setValue(inPoint.X());
			y->setValue(inPoint.Y());
			z->setValue(inPoint.Z());
		}
	}

	void SetEnable(bool inEnable)
	{
		if (IsValid())
		{
			x->setEnabled(inEnable);
			y->setEnabled(inEnable);
			z->setEnabled(inEnable);
		}
	}

	gp_XYZ GetValue() const
	{
		if (IsValid())
		{
			return gp_XYZ(x->value(), y->value(), z->value());
		}
		return gp_XYZ();
	}
};

class QRSWidgetBase : public QWidget
{
public:
    QRSWidgetBase(MainWindow* inMainWindow, ShapeOperation* inOperation = nullptr, QWidget* parent = nullptr);
	~QRSWidgetBase();
protected:
	MainWindow* m_mainWindow;
	ShapeOperation* m_operation;
	bool bIsConfirmed = false;
};

